//
//  NSString+BMLBase64.m
//  24-加密
//
//  Created by GivenBmli on 16/8/16.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "NSString+BMLBase64.h"

@implementation NSString (BMLBase64)
// 编码
- (NSString *)stringWithBase64 {
//    NSString 转 NSData
    NSData *stingData = [self dataUsingEncoding:NSUTF8StringEncoding];
//    NSData进行Base64 生成字符串
  NSString *base64String = [stingData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    return base64String;
}

- (NSData *)base64StringWithData {
    return [[NSData alloc]initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
}

// 解码
- (NSString *)base64WithString {
//    根据Base64字符串,生成NSData
    NSData *base64Data = [[NSData alloc] initWithBase64EncodedString:self options:NSDataBase64DecodingIgnoreUnknownCharacters];
//   把NSData 转成字符串
    NSString *orginSting = [[NSString alloc]initWithData:base64Data encoding:NSUTF8StringEncoding];
    return orginSting;
}


@end
